home *** CD-ROM | disk | FTP | other *** search
- 10 ' By David S. Lay 613-824-6405
- 12 '
- 15 '''''''''''''''''''''''''''''''
- 20 title$=" Mastermind "
- 30 title$=chr$(32)+chr$(14)+chr$(15)+title$
- 40 title$=title$+chr$(14)+chr$(15)+chr$(32)
- 50 gosub 60:goto 170
- 60 poke systab+24,1
- 70 a#=gb
- 80 gintin=peek(a#+8)
- 90 poke gintin+0,peek(systab+8)
- 100 poke gintin+2,2
- 110 s#=gintin+4
- 120 title$=title$+chr$(0)
- 130 poke s#,varptr(title$)
- 140 gemsys(105)
- 150 poke systab+24,0
- 160 return
- 170 fullw 2:clearw 2
- 180 if peek(systab)=4 then 240
- 190 ?:?:?:?
- 200 ?" This program will work only in low resolution."
- 210 ?:?" Please return to the desktop and use the SET PREFERENCES"
- 220 ?" function to select low resolution mode."
- 230 x=inp(2):clearw 2:end
- 240 gotoxy 0,0
- 250 ?:?"I will select up to six coloured pegs
- 260 ?"from ten different colours (duplicates"
- 270 ?"are possible) and you will have ten"
- 280 ?"tries to guess the combination. Enter"
- 290 ?"your guess using the numeric keypad"
- 300 ?"(you can change your guess using the"
- 310 ?"arrow keys) then press ENTER. Each"
- 320 ?"time you make a guess I will provide"
- 330 ?"hints. For every peg which is the"
- 340 ?"right colour and is in the right"
- 350 ?"place, I will show a black peg. For"
- 360 ?"every peg of the right colour but"
- 370 ?"in the wrong place, I will show a"
- 380 ?"white peg."
- 390 ?" Hit Escape to leave the game."
- 400 gotoxy 0,17:?" Select difficulty level (3 to 6)";
- 410 x=inp(2)
- 420 if x=27 then 620
- 430 if x<51 or x>54 goto 410
- 440 dl=x-48
- 450 gosub colset
- 460 randomize 0
- 470 gosub setup
- 480 gosub in
- 490 if fi=0 then 480
- 500 tn=tn+1:for i=1 to dl
- 510 c=gu(i)
- 520 color 1,c,c,1,1
- 530 pcircle i*9+18,145-tn*10,4:next
- 540 gosub boxoff:bn=1:gosub boxon
- 550 gosub check
- 560 if nw=dl then 580
- 570 if tn<10 then 480
- 580 for i=1 to dl:c=gi(i)
- 590 color 1,c,c,1,1:pcircle i*9+18,30,4
- 600 next
- 610 x=inp(2):if x<>27 then tn=0:goto 470
- 620 title$="OUTPUT":gosub 60:gosub colset:clearw 2:end
- 630 check:nb=0:nw=0
- 640 for i=1 to dl
- 650 gis(i)=gi(i)
- 660 gus(i)=gu(i)
- 670 next
- 680 for i=1 to dl
- 690 if gus(i)=gis(i) then nw=nw+1:gis(i)=0:gus(i)=1
- 700 next i
- 710 for i=1 to dl:for j=1 to dl
- 720 if gus(i)=gis(j) then nb=nb+1:gis(j)=0:gus(i)=1
- 730 next j,i:bb=0
- 740 color 1,14,14,1,1:if nw=0 then 780
- 750 for i=1 to nw
- 760 bb=bb+1:pcircle bb*9+78,145-tn*10,3
- 770 next i
- 780 if nb=0 then 830
- 790 color 1,15,15,1,1
- 800 for i=1 to nb
- 810 bb=bb+1:pcircle bb*9+78,145-tn*10,3
- 820 next i
- 830 return
- 840 in:fi=0:x=inp(2)
- 850 if x=27 then 620
- 860 if x=205 and bn<dl then gosub boxoff:bn=bn+1:gosub boxon:return
- 870 if x=203 and bn>1 then gosub boxoff:bn=bn-1:gosub boxon:return
- 880 if x=13 then fi=1:return
- 890 if x>57 or x<48 then return
- 900 c=x-46
- 910 gu(bn)=c
- 920 color 1,c,c,1,1: pcircle bn*10+193,30,4
- 930 x=205:goto 860
- 940 return
- 950 boxon:color 1,14,14,1,1:goto 970
- 960 boxoff:color 1,12,12,1,1
- 970 xp=bn*10+188
- 980 linef xp,25,xp,35:linef xp,35,xp+10,35
- 990 linef xp+10,35,xp+10,25:linef xp+10,25,xp,25
- 1000 return
- 1010 setup:
- 1020 color 1,7,7,1,1:x1=0:x2=320:y1=11:y2=200
- 1030 gosub box
- 1040 x1=11:x2=150:y1=32:y2=172:color 1,12,12
- 1050 gosub box
- 1060 color 1,14,14,1,1
- 1070 linef 10,10,150,10:linef 150,10,150,150
- 1080 linef 150,150,10,150:linef 10,150,10,10
- 1090 color 1,14,14,1,1
- 1100 linef 12,12,148,12:linef 148,12,148,148
- 1110 linef 148,148,12,148:linef 12,148,12,12
- 1120 linef 20,20,20,140
- 1130 linef 20,140,140,140
- 1140 linef 140,140,140,20
- 1150 linef 140,20,20,20
- 1160 linef 80,20,80,140
- 1170 for i=40 to 130 step 10
- 1180 linef 20,i,140,i:next
- 1190 for i=1 to dl
- 1200 pv=int(rnd*10)+2
- 1210 gi(i)=pv
- 1220 next
- 1230 color 1,14,14,1,1
- 1240 for i=27 to dl*9+19 step 9
- 1250 pcircle i,30,4:next
- 1260 x1=191:x2=266:y1=67:y2=162
- 1270 color 1,12,12:gosub box
- 1280 color 1,2,2,1,1
- 1290 x1=201:y1=152:y2=137:x2=236
- 1300 gosub box
- 1310 color 1,3,3,1,1
- 1320 x1=201:y1=132:y2=117:x2=216
- 1330 gosub box
- 1340 color 1,4,4,1,1
- 1350 x1=221:x2=236:gosub box
- 1360 color 1,5,5,1,1
- 1370 x1=241:x2=256:gosub box
- 1380 color 1,6,6,1,1
- 1390 x1=201:y1=112:y2=97:x2=216
- 1400 gosub box
- 1410 color 1,7,7,1,1
- 1420 x1=221:x2=236:gosub box
- 1430 color 1,8,8,1,1
- 1440 x1=241:x2=256:gosub box
- 1450 color 1,9,9,1,1
- 1460 x1=201:y1=92:y2=77:x2=216
- 1470 gosub box
- 1480 color 1,10,10,1,1
- 1490 x1=221:x2=236:gosub box
- 1500 color 1,11,11,1,1
- 1510 x1=241:x2=256:gosub box
- 1520 x1=191:x2=266:y1=42:y2=63
- 1530 color 1,12,12:gosub box
- 1540 bn=1:gosub boxon
- 1550 return
- 1560 colset:
- 1570 poke contrl, 14:poke contrl+2,0
- 1580 poke contrl+6,4
- 1590 for colour=0 to 15:read r,g,b
- 1600 redlev=r*1000/7
- 1610 grnlev=g*1000/7
- 1620 blulev=b*1000/7
- 1630 poke intin, colour
- 1640 poke intin+2, redlev
- 1650 poke intin+4, grnlev
- 1660 poke intin+6, blulev
- 1670 vdisys(1)
- 1680 next colour:return
- 1690 data 0,5,0,0,5,0,7,0,0,0,7,0
- 1700 data 0,0,7,0,0,3,5,2,0,0,5,0
- 1710 data 7,7,0,7,0,7,0,7,7,0,5,5
- 1720 data 5,5,5,5,0,5,0,0,0,7,7,7
- 1730 ' normal colours
- 1740 data 7,7,7,0,0,0,7,0,0,0,7,0,0,0,7
- 1750 data 0,0,5,5,2,0,0,5,0,5,5,5
- 1760 data 2,2,2,0,7,7,0,5,5,7,0,7
- 1770 data 5,0,5,7,7,0,5,5,0
- 1780 box: rem VDI box draw routine
- 1790 poke contrl,11
- 1800 poke contrl+2,2
- 1810 poke contrl+6,0
- 1820 poke contrl+10,1
- 1830 poke ptsin,x1
- 1840 poke ptsin+2,y1
- 1850 poke ptsin+4,x2
- 1860 poke ptsin+6,y2
- 1870 vdisys(1)
- 1880 return
- əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə